package cn.cs.service;

import cn.cs.mapper.AfterOrderMapper;
import cn.cs.pojo.AfterOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
public class RestAfterOrderService {

    @Resource
    private AfterOrderMapper mapper;

    @RequestMapping(value = "/getAfterOrderList", method = RequestMethod.POST)
    @Transactional
    public List<AfterOrder> getAfterOrderList(@RequestBody Map<String, Object> param) {
        return mapper.getAfterOrderList(param);
    }
    @RequestMapping(value = "/updateAfterOrder", method = RequestMethod.POST)
    @Transactional
    public int updateAfterOrder(@RequestBody AfterOrder order) {
        return mapper.updateAfterOrder(order);
    }


    @RequestMapping(value = "/getAfterOrderByUserIdAndOrderId", method = RequestMethod.POST)
    public List<Map<String, Object>> getAfterOrderByUserIdAndOrderId(@RequestParam("orderId") String orderId) throws Exception{
        return mapper.getAfterOrderByUserIdAndOrderId(orderId);
    }

    @RequestMapping(value = "/getAfterOrderByUserId", method = RequestMethod.POST)
    public List<Map<String, Object>> getAfterOrderByUserId(@RequestParam("orderId") String orderId, @RequestParam("userId") String userId, @RequestParam("id") String id) throws Exception{
        return mapper.getAfterOrderByUserId(orderId, userId, id);
    }

    @RequestMapping(value = "/addAfterOrder", method = RequestMethod.POST)
    public Integer addAfterOrder(@RequestBody AfterOrder afterOrder) throws Exception{
        return mapper.insertAfterOrder(afterOrder);
    }

    @RequestMapping(value = "/modifyAfterOrder", method = RequestMethod.POST)
    public Integer modifyAfterOrder(@RequestBody AfterOrder afterOrder) throws Exception{
        return mapper.updateAfterOrder(afterOrder);
    }

    @RequestMapping(value = "/getAfterOrderByOrderIdOne", method = RequestMethod.POST)
    public AfterOrder getAfterOrderByOrderIdOne(@RequestParam("orderId") String orderId) throws Exception{
        return mapper.getAfterOrderByOrderIdOne(orderId);
    }

    @RequestMapping(value = "/getAfterOrderCountByMap", method = RequestMethod.POST)
    public Integer getAfterOrderCountByMap(@RequestBody Map<String, Object> param) throws Exception{
        return mapper.getAfterOrderCountByMap(param);
    }

    @RequestMapping(value = "/getAfterOrderListPage", method = RequestMethod.POST)
    public List<Map<String, Object>> getAfterOrderListPage(@RequestBody Map<String, Object> param) throws Exception{
        return mapper.getAfterOrderListPage(param);
    }

    @RequestMapping(value = "/getAfterOrderAllCountByMap", method = RequestMethod.POST)
    public Integer getAfterOrderAllCountByMap(@RequestBody Map<String, Object> param) throws Exception{
        return mapper.getAfterOrderAllCountByMap(param);
    }

    @RequestMapping(value = "/getAfterOrderAllListPage", method = RequestMethod.POST)
    public List<Map<String, Object>> getAfterOrderAllListPage(@RequestBody Map<String, Object> param) throws Exception{
        return mapper.getAfterOrderAllListPage(param);
    }

}
